package edu.cmu.cs211.exprtree.tests;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import edu.cmu.cs211.exprtree.ast.VariableExpression;

public abstract class VariableExpressionTest extends ExpressionTestUtil {
	
	public abstract VariableExpression createExpr(String name);

	@Test
	public void testConstructor() {
		VariableExpression x = createExpr("x");
		assertEquals("x", "x", x.getName());
		VariableExpression y = createExpr("y");
		assertEquals("y", "y", y.getName());
	}

	@Test(expected = NullPointerException.class)
	public void testValueNull() {
		createExpr(null);
	}


	public void toStringTest(String operand) {
		VariableExpression x1 = createExpr("x1");
		VariableExpression x2 = createExpr("x2");
		
		assertEquals("toString incorrect", "x1", x1
				.toString());
		assertEquals("toString incorrect","x2", x2
				.toString());
	}

}
